<?php
namespace app\back\controller;
class Activity extends  \app\back\controller\BaseAdmin{


    function list(){

        $Activity=new \app\model\Activity();
        $res=$Activity->getPage();

        //var_dump($res);
        //var_dump(object2array($res));
        return $this->fetch("./activity_list",['list'=>$res]);
    }

    function add(){
        $Activity=new \app\model\Activity();
        if(request()->isPost()){
            $r=$Activity->add_info(request()->param());
            if($r){
                return $this->success_tip("提交成功",url('list'));
            }
        }else{
            return $this->fetch("./activity_add");
        }
    }

    function del(){
        $params=request()->param();
        if($params['id']==false){
            return $this->error_tip("id不能为空");
        }
        $Activity=new \app\model\Activity();
        $r=$Activity->del_info($params['id']);
        if($r){
            return $this->success_tip("删除成功",url('list'));
        }else{
            return $this->error_tip('删除失败');
        }

    }
    function edit(){
        $Activity=new \app\model\Activity();
        if(request()->isPost()){
            $params=request()->param();
            $r=$Activity->edit_info($params['id'],$params);
            if($r){
                return $this->success_tip("提交成功",url('list'));
            }else{
                return $this->error_tip("提交失败");
            }
        }else{
            $info=$Activity->get_info(request()->param('id'));
            return $this->fetch("./activity_edit",['info'=>$info]);
        }
    }


}